home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / misc / MCPPReload.lha / MCPPReload / Source / misc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-14  |  1.3 KB  |  77 lines

  1. #include <OSIncludes.h>
  2.  
  3. #pragma header
  4.  
  5. extern struct IntuitionBase *IntuitionBase;
  6. extern struct GfxBase *GfxBase;
  7.  
  8. void CalcVisibleSize(struct Screen *scr,WORD *width, WORD *height)
  9. {
  10.     struct TagItem cmtags[]={VTAG_VIEWPORTEXTRA_GET,0,
  11.                                      TAG_DONE};
  12.  
  13.     struct Rectangle myrect;
  14.     struct ViewPortExtra *vpe;
  15.     ULONG displayid;
  16.     WORD x,y;
  17.  
  18.     if(!VideoControl(scr->ViewPort.ColorMap,cmtags))
  19.     {
  20.         vpe=(struct ViewPortExtra *)cmtags[0].ti_Data;
  21.     } else {
  22.         vpe=scr->ViewPort.ColorMap->cm_vpe;
  23.         if(!vpe)
  24.         {
  25.             vpe=(struct ViewPortExtra *)GfxLookUp(&scr->ViewPort);
  26.         }
  27.     }
  28.  
  29.     if(vpe && ((displayid=GetVPModeID(&scr->ViewPort)) != INVALID_ID))
  30.     {
  31.         QueryOverscan(displayid,&myrect,OSCAN_TEXT);
  32.  
  33.         x=vpe->DisplayClip.MaxX - vpe->DisplayClip.MinX + 1;
  34.         y=vpe->DisplayClip.MaxY - vpe->DisplayClip.MinY + 1;
  35.  
  36.         if(x < (myrect.MaxX - myrect.MinX + 1))
  37.         {
  38.             x=myrect.MaxX - myrect.MinX + 1;
  39.         }
  40.         
  41.         if(y < (myrect.MaxY - myrect. MinY + 1))
  42.         {
  43.             y=myrect.MaxY - myrect.MinY + 1;
  44.         }
  45.         
  46.     } else {
  47.  
  48.         x=scr->Width;
  49.         y=scr->Height;
  50.  
  51.     }
  52.     
  53.     *width = x;
  54.     *height = y;
  55.  
  56. }
  57.  
  58. void CalcCenteredWin(struct Screen *scr,WORD winwidth,WORD winheight,WORD *left,WORD *top)
  59. {
  60.     WORD x,y;
  61.  
  62.     CalcVisibleSize(scr,&x,&y);
  63.     
  64.     x=(x - winwidth) / 2;
  65.     y=(y - winheight) / 2;
  66.  
  67.     x -= scr->LeftEdge;
  68.     y -= scr->TopEdge;
  69.  
  70.     if (x<0) x=0;
  71.     if (y<0) y=0;
  72.     
  73.     *left=x;
  74.     *top=y;
  75. }
  76.  
  77.